package com.woorigil.social;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.mobile.device.Device;
import org.springframework.mobile.device.DeviceResolver;
import org.springframework.mobile.device.LiteDeviceResolver;


public class WebUtils {
	public static boolean isMobileDevice (HttpServletRequest request) {
		DeviceResolver deviceResolver = new LiteDeviceResolver();
		Device device = deviceResolver.resolveDevice(request);
		
		// LiteDeviceResolver 내부에서 사용하는 정보로 iPad 기기 인식 불가
		String userAgent = StringUtils.trimToEmpty(request.getHeader("user-agent"));
		if (userAgent.contains("iPad")) {
			return true;
		}
		
		if (device == null) return false;	
		return device.isMobile();
	}
}
